<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="../lib/vue2.6.10.js"></script>
</head>

<body>
    <div id="app">
        <p><input type="text" v-model="msg1"></p>
        <p>{{ msg1.split('').reverse().join('') }}</p>
    </div>
    <hr>
    <div id="example">
        <input type="text" v-model="message">
        <p>Original message: "{{ message }}"</p>
        <p>Computed reversed message: "{{ reversedMessage }}"</p>
    </div>
    <script>
        var app = new Vue({
            el: '#app',
            data: {
                msg1: ''
            }
        });

        var vm = new Vue({
            el: '#example',
            data: {
                message: 'Hello'
            },
            computed: {
                // 计算属性的 getter
                reversedMessage: function () {
                    // `this` 指向 vm 实例
                    return this.message.split('').reverse().join('')
                }
            }
        });
    </script>
</body>

</html>